package models.mappers;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import vos.MenuSearchVo;
import vos.SystemMenuView;
import models.Operator;
import models.Role;
import models.RoleMenu;
import models.RoleUser;
import models.SystemMenu;

public interface RoleMenuMapper {
	/**
	 * 获取已启用角色列表
	 *
	 * @Title: getRole 
	 * @return
	 * @return: List<Role>
	 */
	@Select("select roleid,rolename from "
			+ Role.TABLE_NAME
			+" where isflag=0")
	List<Role> getRole();
	/**
	 * 根据角色id获取角色用户
	 *
	 * @Title: getRoleOperator 
	 * @param roleid
	 * @return
	 * @return: List<String>
	 */
	@Select("select menuid from "
			+ RoleMenu.TABLE_NAME
			+" where roleid=#{roleid} and ismenu=false")
	List<String> getRoleMenu(String roleid);
	/**
	 * 保存角色用户
	 *
	 * @Title: saveRoleUser 
	 * @param smap
	 * @return
	 * @return: boolean
	 */
	boolean saveRoleMenu(Map<String, List<RoleMenu>> smap);
	/**
	 * 删除角色用户
	 *
	 * @Title: deleteRoleUser 
	 * @param roleid
	 * @return: void
	 */
	@Delete("delete from "
			+ RoleMenu.TABLE_NAME
			+" where roleid=#{roleid}")
	void deleteRoleMenu(String roleid);
	/**
	 * 统计启用的菜单
	 *
	 * @Title: countUseMenu 
	 * @param vo
	 * @return
	 * @return: long
	 */
	long countUseMenu(MenuSearchVo vo);
	/**
	 * 获取启用的菜单
	 *
	 * @Title: listUseMenu 
	 * @param vo
	 * @return
	 * @return: List<Operator>
	 */
	List<Operator> listUseMenu(MenuSearchVo vo);
	@Select("select menuid,menuname,parentid,isend from "
			+ SystemMenu.TABLE_NAME
			+" where isend=false and isflag=false order by sort asc")
	List<SystemMenu> getUseMenu();
	/**
	 * 获取子菜单
	 *
	 * @Title: getMenus 
	 * @param menuid 菜单id
	 * @return
	 * @return: List<SystemMenu>
	 */
	@Select("select menuid,menuname,parentid,isend from "
			+ SystemMenu.TABLE_NAME
			+" where isflag=false and parentid=#{menuid} order by sort asc")
	List<SystemMenu> getMenus(String menuid);
	
}
